//news.js
//获取应用实例
var httpRootPath = 'https://www.yn-etc.com/yn_portal_api';
var app = getApp()
Page({
  data: {
    newsList: [],
    warnInfo: "页面中没有加css，凑活着看吧"
  },
  onLoad: function () {
    var that = this
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 1500
    })
    wx.request({
      url: httpRootPath + '/infocontents',
      data: {
        currentPage: 1,
        pageSize: 50
      },
      dataType: 'json',
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: { 'content-type': 'application/json' }, // 设置请求的 header
      success: function (res) {
        // success
        console.log(res);
        var status = res.data.status;
        var newsList = res.data.data.object;
        console.log(newsList)
        if (status == '0') {
          that.setData({
            newsList: newsList
          }),
            that.update()
        } else {
          that.setData({
            newsList: '信息列表获取错误'
          })
          console.error('信息列表获取错误');
        }
      },
      fail: function () {
        // fail
      },
      complete: function () {
        // complete
      }
    })
  }
})